package main

import "fmt"

type OrderedStream struct {
	values []string
	ptr    int
	n      int
}

func Constructor1656(n int) OrderedStream {
	values := make([]string, n+1)
	return OrderedStream{
		values: values,
		ptr:    1,
		n:      n + 1,
	}
}

func (this *OrderedStream) Insert(idKey int, value string) []string {
	this.values[idKey] = value
	cur := this.ptr
	for i := this.ptr; i < this.n && this.values[i] != ""; i++ {
		this.ptr += 1
	}
	return this.values[cur:this.ptr]
}

func main() {
	obj := Constructor1656(5)
	fmt.Printf("%+v\n", obj.Insert(3, "ccccc"))
	fmt.Printf("%+v\n", obj.Insert(1, "aaaaa"))
	fmt.Printf("%+v\n", obj.Insert(2, "bbbbb"))
	fmt.Printf("%+v\n", obj.Insert(5, "eeeee"))
	fmt.Printf("%+v\n", obj.Insert(4, "ddddd"))
}
